﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 依赖综合案例.ConfigServices
{
    public class LayeredConfigReader : IconfigReader
    {
        private readonly IEnumerable<IConfigProjects> servers; // 所有实现IConfigProjects接口的类
        public LayeredConfigReader(IEnumerable<IConfigProjects> servers) 
        {
            this.servers = servers;
        }
        public string GetValue(string name)
        {
            Console.WriteLine("**************************");
            string value = null;
            foreach (var item in servers)
            {
                Console.WriteLine(item.GetType());
                string newValue = item.GetValue(name);
                Console.WriteLine(newValue);
                if (newValue != null)
                {
                    value = newValue;
                }
               
            }
            Console.WriteLine("**************************");
            return value;
            
        }
    }
}
